package com.ljx.itbbs.server.article.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ljx.itbbs.server.article.dao.CollectRecordDao;
import com.ljx.itbbs.server.article.domain.entity.CollectRecordEntity;
import com.ljx.itbbs.server.article.domain.vo.req.ArticleCollectReq;
import com.ljx.itbbs.server.article.service.CollectRecordService;
import com.ljx.itbbs.server.article.service.adapter.ArticleAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CollectRecordServiceImpl implements CollectRecordService {

    @Autowired
    private CollectRecordDao collectRecordDao;

    @Override
    public CollectRecordEntity getCollectRecord(String objKey, Long userId) {
        return collectRecordDao.collectRecordDao(objKey, userId);
    }

    @Override
    public void saveCollectRecord(String objKey, Long userId, Integer type) {
        collectRecordDao.save(ArticleAdapter.buildCollectRecordSave(objKey, userId, type));
    }

    @Override
    public List<CollectRecordEntity> getCollectRecordListByUId(Long uid) {
        return collectRecordDao.getCollectRecordListByUId(uid);
    }

    @Override
    public IPage<CollectRecordEntity> getCollectRecordList(ArticleCollectReq req, Long uid) {
        return collectRecordDao.getCollectRecordList(req, uid);
    }

    @Override
    public void deleteCollectRecord(Long userId, String collectObj) {
        collectRecordDao.deleteCollectRecord(userId, collectObj);
    }
}
